#!/usr/bin/env bash
# post-receive
zero_commit="0000000000000000000000000000000000000000"
#set -e
while read oldrev newrev refname; do 
  # branch or tag get deleted 
  if [ "$newrev" = "$zero_commit" ]; then 
    continue 
  fi 
 
  # Check for new branch or tag 
  if [ "$oldrev" = "$zero_commit" ]; then 
    span=`git rev-list $newrev` 
  else 
    span=`git rev-list $oldrev..$newrev` 
  fi 
 
  for COMMIT in $span; 
   do
    ## 包含关心的目录,然后通过get请求通知远程主机
     web_dir=`git log -n 1 --stat --oneline ${COMMIT} | grep web | wc -l`
     if [ $web_dir -gt 0 ]
     then
	
	curl -m 10 http://192.168.1.29:8000/$RTUSER/$web_dir>>/dev/null 2>&1 &
	exit 0
     fi
   done
done

